home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 29
/
Volume 29 - JOGO DISK .iso
/
Games
/
jungle_adventure.swf
/
scripts
/
__Packages
/
RGB.as
< prev
next >
Wrap
Text File
|
2006-11-29
|
2KB
|
75 lines
class RGB extends Number
{
var r = 0;
var g = 0;
var b = 0;
function RGB(r, g, b)
{
super();
switch(arguments.length)
{
case 3:
this.r = r;
this.g = g;
this.b = b;
break;
case 0:
break;
case 1:
this.hex(r);
}
}
function hex(i)
{
this.r = i >>> 16;
this.g = i - (this.r << 16) >>> 8;
this.b = i % 256;
}
function toHex()
{
var _loc4_ = (this.r << 16) + (this.g << 8) + this.b;
var _loc5_ = "";
var _loc3_ = 20;
while(_loc3_ > -1)
{
var _loc2_ = _loc4_ >>> _loc3_;
_loc5_ += _loc2_ <= 9 ? _loc2_ : chr(55 + _loc2_);
_loc4_ -= _loc2_ << _loc3_;
_loc3_ -= 4;
}
return "0x" + _loc5_;
}
function addChannel(ir, ig, ib)
{
this.r += ir;
this.g += ig;
this.b += ib;
}
function subChannel(ir, ig, ib)
{
this.r -= ir;
this.g -= ig;
this.b -= ib;
}
function addColor(v)
{
this.r += v.r;
this.g += v.g;
this.b += v.b;
}
function subColor(v)
{
this.r -= v.r;
this.g -= v.g;
this.b -= v.b;
}
function valueOf()
{
return (this.r << 16) + (this.g << 8) + this.b;
}
function toString()
{
return "RGB(" + this.r + "," + this.g + "," + this.b + ")";
}
}